package serializer

import (
	"app/model"
	"time"
)

type User struct {
	ID        uint   `json:"id" form:"id" example:"1"`                  // 用户ID
	Username  string `json:"username" form:"username" example:"FanOne"` // 用户名
	CreatedAt string `json:"create_time"`
	Token     string `json:"token"`
}

// BuildUser 序列化用户
func BuildUser(item model.User) User {
	return User{
		ID:        item.ID,
		Username:  item.Username,
		CreatedAt: time.Unix(item.CreatedAt, 0).Format("2006-01-02 15:04:05"),
		Token:     item.Token,
	}
}
